import requests

import coo
import 获取调度系统ID


# -*- coding: utf-8 -*-

class 查询事项信息:
    cookies = coo.cookies
    headers = coo.headers
    ur = '59.215.206.188'
    dispatch = 'ddglzy'
    def query(self,itemName, regCode):
        url = 'http://{}/{}/dispatch/resourse/itemconfigure/query'.format(self.ur, self.dispatch)
        data = {
            "itemcode": "",
            "itemname": "{}".format(itemName),
            "regName": "",
            "regCode": "{}".format(regCode),
            # "itemname": "房地产开发项目前期物业服务合同备案",
            # "regName": "遵义市",
            # "regCode": "520300",
            "orgName": "",
            "orgCode": "",
            "type": "",
            "_search": "true",
            "nd": "",
            "rows": "1000",
            "page": "1",
            "sidx": "sort",
            "sord": "asc",
        }
        x = requests.post(url, data=data, cookies=self.cookies, headers=self.headers).json()
        #print(x.text)
        list=[]
        for i in x['rows']:
            itemId = i['cell']['ID']
            exchangeCode = itemCode = i['cell']['CODE']
            organName = i['cell']['ORG_NAME']
            organCode = i['cell']['ORG_CODE']
            version = i['cell']['VERSION']
            areaCode = i['cell']['REGION_CODE']
            areaName = i['cell']['REGION_NAME']
            itemTime = i['cell']['AGREE_TIME']
            NAME = i['cell']['NAME']
            ids = 获取调度系统ID.getID().getID(itemId, itemCode, version)
            list.append([itemId, exchangeCode, itemCode, organName, organCode, version, areaCode, areaName, itemTime, NAME,ids])
        # print(itemId,exchangeCode,itemCode,organName,organCode,version,areaCode,areaName,itemTime,NAME)
        # print(list)
        return list

